#include "selectfriendscrollarea.h"
#include<QScrollBar>
#include <QVBoxLayout>
SelectFriendScrollArea::SelectFriendScrollArea(QWidget *parent)
    :QScrollArea(parent)
{
    mylayout=new QVBoxLayout();
    mylayout->setContentsMargins(5,5,5,5);
    mylayout->setSpacing(0);
    mylayout->setAlignment(Qt::AlignTop);
    contain=new QWidget();
    contain->setLayout(mylayout);
    this->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    this->setWidget(contain);
    this->setWidgetResizable(true);

    // 浅色主题滚动条样式
    this->verticalScrollBar()->setStyleSheet(
        "QScrollBar:vertical {"
        "   width: 10px;"
        "   background: #f8f9fa;"
        "   border-radius: 5px;"
        "   margin: 2px;"
        "}"
        "QScrollBar::handle:vertical {"
        "   background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
        "               stop:0 #6c757d, stop:1 #495057);"
        "   border-radius: 5px;"
        "   min-height: 30px;"
        "}"
        "QScrollBar::handle:vertical:hover {"
        "   background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
        "               stop:0 #5a6268, stop:1 #343a40);"
        "}"
        "QScrollBar::handle:vertical:pressed {"
        "   background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
        "               stop:0 #495057, stop:1 #212529);"
        "}"
        "QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {"
        "   border: none;"
        "   background: none;"
        "   height: 0px;"
        "}"
        "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
        "   background: none;"
        "}");
    this->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal { height: 0px; }");

    //设置浅色主题背景和边框
    this->setStyleSheet(
        "SelectFriendScrollArea {"
        "   background: #ffffff;"
        "   border: 1px solid #dee2e6;"
        "   border-radius: 8px;"
        "}"
        "QScrollArea {"
        "   background: #ffffff;"
        "   border: none;"
        "   border-radius: 8px;"
        "}"
        );
}

QWidget *SelectFriendScrollArea::getContain()
{
    return this->contain;
}





